package com.kun.portal.webframe.po;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.kun.portal.webframe.util.Loaded;
import com.kun.portal.webframe.util.Status;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;

/**
 * Created by Administrator on 2018-09-05.
 *
 * 停机位配置管理
 */
@Entity
@Table(
        name = "fbo_gp_config"
)
@JsonSerialize
public class GpConfigPo implements Serializable {
    @Id
    @GeneratedValue(
            generator = "gp_id"
    )

    @GenericGenerator(
            name = "gp_id",
            strategy = "uuid"
    )
    @Column(
            name = "gp_id",
            length = 32,
            nullable = false
    )
    private String gpId;
    @Column(
            name = "gp_name",
            length = 32
    )
    private String gpName;
    @Column(
            name = "gp_num",
            length = 32
    )
    private String gpNum;

    @Column(
            name = "apron",
            length = 32
    )
    private  String apron;

    @Column(
            name = "gp_type",
            length = 32
    )
    private String gpType;
    @Column(
            name = "gp_state",
            length = 32
    )
    private String gpState;
    @Column(
            name = "px",
            length = 32
    )
    private String px;
    @Column(
            name = "py",
            length = 32
    )
    private String  py;

    @Column(
            name = "run_status",
            length = 32
    )
    private Integer runStatus= Status.AerodromeStatus.FREE;

    @OneToOne(targetEntity =FlightInfoPo.class,cascade = CascadeType.DETACH ,fetch = FetchType.LAZY,mappedBy = "gpConfigPo")
    @JoinColumn(name="flight_info_id",referencedColumnName="flight_info_id",nullable=true)
    private FlightInfoPo currentFlight;

    @OneToMany(targetEntity =GatePositionOccupyDistribution.class,cascade = CascadeType.DETACH ,fetch = FetchType.LAZY,mappedBy = "gpConfigPo")
    private Set<GatePositionOccupyDistribution > gatePODs;

    public String getGpId() {
        return gpId;
    }

    public void setGpId(String gpId) {
        this.gpId = gpId;
    }

    public String getGpName() {
        return gpName;
    }

    public void setGpName(String gpName) {
        this.gpName = gpName;
    }

    public String getGpNum() {
        return gpNum;
    }

    public void setGpNum(String gpNum) {
        this.gpNum = gpNum;
    }

    public String getGpType() {
        return gpType;
    }

    public void setGpType(String gpType) {
        this.gpType = gpType;
    }

    public String getGpState() {
        return gpState;
    }

    public void setGpState(String gpState) {
        this.gpState = gpState;
    }

    public String  getPx() {
        return px;
    }

    public void setPx(String  px) {
        this.px = px;
    }

    public String  getPy() {
        return py;
    }

    public void setPy(String  py) {
        this.py = py;
    }

    public Integer getRunStatus() {
        return runStatus;
    }

    public void setRunStatus(Integer runStatus) {
        this.runStatus = runStatus;
    }

    public FlightInfoPo getCurrentFlight() {
        return (FlightInfoPo) Loaded.loaded(currentFlight);
    }

    public void setCurrentFlight(FlightInfoPo currentFlight) {
        this.currentFlight = currentFlight;
    }

    public String getApron() {
        return apron;
    }

    public void setApron(String apron) {
        this.apron = apron;
    }


    public Set<GatePositionOccupyDistribution> getGatePODs() {

        return (Set<GatePositionOccupyDistribution>) Loaded.loaded(gatePODs);
    }

    public void setGatePODs(Set<GatePositionOccupyDistribution> gatePODs) {
        this.gatePODs = gatePODs;
    }
}
